]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
tray/na-xembed: Use XShape to remove input on socket window
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Wed, 1 May 2024 20:34:58 +0000 (22:34 +0200)
committerMarge Bot <marge-bot@gnome.org>
Wed, 27 Aug 2025 18:33:13 +0000 (18:33 +0000)
We don't want this window to take any input as, a part from blocking the
events on the shell representation itself, they may potentially make the
plugged window to do anything with the event is processing (such as
showing tooltips). And we don't want this since we only want to send to
those windows only the synthetic events that we explicitly control.

This was already the case before of commit ab60902058 but a similar
approach was not replicated, leading to input events being fully
processed from tray icons plugs.

It requires adding an explicit build dependency on Xext, but this is
something that mutter already depends on so not really a new dependency

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7613
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3818>

meson.build
src/tray/meson.build
src/tray/na-xembed.c

index b4f8058b953697dd4ff7ba76cd20d966a3a070ca..2f257d6a4a9411bbe134c5ea9ee5c95d9da4d8a3 100644 (file)
@@ -92,6 +92,7 @@ have_x11 = mutter_dep.get_variable('have_x11') == 'true'
 have_x11_client = mutter_dep.get_variable('have_x11_client') == 'true'
 if have_x11_client or have_x11
   x11_dep = dependency('x11')
+  xext_dep = dependency('xext')
   xfixes_dep = dependency('xfixes')
 endif
 
index 2fc73f3a48af72140f3b7d50f8200af4ae06cab9..c91e94044dd83723e1a248e24b17a4f39f588c48 100644 (file)
@@ -9,6 +9,6 @@ tray_sources = [
 
 libtray = static_library('tray', tray_sources,
   c_args: ['-DG_LOG_DOMAIN="notification_area"'],
-  dependencies: [mutter_dep, mtk_dep, xfixes_dep],
+  dependencies: [mutter_dep, mtk_dep, xfixes_dep, xext_dep],
   include_directories: conf_inc
 )
index 75af21adb21d0d333a126439609ebca7b4f1dd51..1a919397432f3702a43c52ecf7f98d25c43fee29 100644 (file)
@@ -24,6 +24,7 @@
 #include "na-xembed.h"
 
 #include <mtk/mtk-x11.h>
+#include <X11/extensions/shape.h>
 #include <X11/extensions/Xfixes.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
@@ -362,6 +363,7 @@ na_xembed_add_window (NaXembed  *xembed,
     {
       XSetWindowAttributes socket_attrs;
       XWindowAttributes plug_attrs;
+      int shape_major, shape_minor;
       int result;
 
       result = XGetWindowAttributes (xdisplay, priv->plug_window, &plug_attrs);
@@ -407,6 +409,19 @@ na_xembed_add_window (NaXembed  *xembed,
                        priv->plug_window,
                        priv->socket_window,
                        0, 0);
+
+      /* Set an empty input shape on the window so that the socket does not
+       * get any input. Without this the tray may still get events and - for
+       * instance - show tooltips on hover which we don't want.
+       * This is the quickest way to achieve this, without having to deal these
+       * windows with specific code in mutter.
+       */
+      if (XShapeQueryExtension (xdisplay, &shape_major, &shape_minor))
+        {
+          XShapeSelectInput (xdisplay, priv->socket_window, NoEventMask);
+          XShapeCombineRectangles (xdisplay, priv->socket_window, ShapeInput,
+                                   0, 0, NULL, 0, ShapeSet, 0);
+        }
     }
 
   priv->have_size = FALSE;